// /////////////////////////////////////////////////////////////////////////////
//
// Name:            AssetProcessor.h
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Declaration of the AssetProcessor class.
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

#ifndef __ASSETPROCESSOR_H__
#define __ASSETPROCESSOR_H__

// Include files
#include "../dependencies.h"
#include "ReferenceCounted.h"
#include "AssetGroup.h"

// Forward declarations
class AssetGroup;


// AssetProcessor class
//! The AssetProcessor class is responsible for processing all assets in a sub-directory of an
//! AssetGroup. Behaviour for specific assets is implemented by deriving from the AssetProcessor
//! class.
class AssetProcessor : public ReferenceCounted
{
    friend class AssetGroup;

public:

    // Initialisation and deinitialisation
    //! Constructor
    AssetProcessor(AssetGroup *parent, const std::string &baseName);
    //! Deconstructor
    ~AssetProcessor();

    // Public methods
    //! Returns the base name.
    const std::string& getBaseName() const;
    //! Gets the parent of this processor.
    AssetGroup* getParent() const;

    //! Reloads the asset with the given filename.
    //! @param fileName      Filename of the asset.
    //! @return True on succesful reload, false otherwise.
    virtual bool reloadAsset(const std::string &fileName);
    //! Reloads all assets.
    virtual void reloadAssets();

    //! Removes the asset with the given filename.
    //! @param fileName      Filename of the asset.
    //! @return True on succesful removal, false otherwise.
    virtual bool removeAsset(const std::string &fileName);
    //! Removes all assets.
    virtual void removeAssets();

protected:

    // Protected methods
    //! Loads the asset with the given filename.
    //! @param fileName      Filename of the asset.
    //! @return True on succesful loading, false otherwise.
    virtual bool loadAsset(const std::string &fileName);
    //! Loads all assets.
    virtual void loadAssets();

    // Protected members
    //! Parent of this processor.
    AssetGroup *pParent;
    //! The base name is the name (i.e. meshes) of the directory that this processor will process.
    std::string mBaseName;
};

#endif
